//
// Created by ziya on 2021/4/26.
//

#include "../../include/common.h"
#include "../../include/jni/com_ziya_jvm_jdk_classes_sun_misc_Unsafe.h"
#include "../../share/vm/oops/InstanceKlass.h"

/*
 * Class:     com_ziya_jvm_jdk_classes_sun_misc_Unsafe
 * Method:    allocateMemory
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_com_ziya_jvm_jdk_classes_sun_misc_Unsafe_allocateMemory
        (JNIEnv *env, jobject obj, jlong size)
{
    INFO_PRINT("hello\n");

    return 0;
}

/*
 * Class:     com_ziya_jvm_jdk_classes_sun_misc_Unsafe
 * Method:    allocateObject
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_com_ziya_jvm_jdk_classes_sun_misc_Unsafe_allocateObject
        (JNIEnv *env, jclass clazz)
{
    InstanceKlass* klass = new InstanceKlass;

    instanceOop i = klass->allocate_instance(16);

    return (jlong) i;
}

/*
 * Class:     com_ziya_jvm_jdk_classes_sun_misc_Unsafe
 * Method:    initMemoryModel
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_com_ziya_jvm_jdk_classes_sun_misc_Unsafe_initMemoryModel
        (JNIEnv *env, jclass clazz) {

}
